import React from "react";
import { List } from "antd-mobile";
import { useParams } from "react-router-dom";
import { saveHistory } from "../../../store/slice/ticketSlice";
import { useDispatch } from "react-redux";
function CitySearch(props) {
  let params = useParams();
  let dis = useDispatch();
  return (
    <div>
      <List>
        {props.list.map((item, index) => {
          return (
            <List.Item
              key={index}
              onClick={() => {
                //跳转首页
                props.saveCity(params.type, item.name);
                //搜索历史
                dis(saveHistory(item.name));
              }}
            >
              {item.name}
            </List.Item>
          );
        })}
      </List>
    </div>
  );
}

export default CitySearch;
